package com.test.prolenders.bean_prolenders.process_prolenders;

import android.text.TextUtils;

import com.google.gson.Gson;
import com.google.gson.JsonArray;

import java.util.ArrayList;


public class ProcessInfo_Step_prolenders {

    private ProcessInfo_Step_prolenders(){}

    private String apiUrl;
    private String title;
    private String text;
    private JsonArray dataList;
    private JsonArray extDataList;
    private String showTopTips;
    private String itemCount;
    private String isContact;
    private String contactParamName;
    private ArrayList<ArrayList<String>> relationShips;


    public String getApiUrl() {
        if (TextUtils.isEmpty(apiUrl)) return "";
        return apiUrl;
    }

    public String getTitle() {
        if (TextUtils.isEmpty(title)) return "";
        return title;
    }

    public String getText(){
        if (TextUtils.isEmpty(text)) return "";
        return text;
    }

    public boolean showTopTips(){
        if (TextUtils.isEmpty(apiUrl)) return false;
        return showTopTips.equalsIgnoreCase("YES");
    }

    public int getDataListSize(){
        if (dataList==null) return 0;
        return dataList.size();
    }

    public ProcessInfo_Data_prolenders getProcessData(int index){
        if (index<0||index>=dataList.size()) return null;
        return new Gson().fromJson(dataList.get(index).toString(), ProcessInfo_Data_prolenders.class);
    }

    public int getExtDataListSize(){
        if (extDataList == null) return 0;
        return extDataList.size();
    }

    public ProcessInfo_Data_prolenders getExtProcessData(int index){
        if (index<0||index>=extDataList.size()) return null;
        return new Gson().fromJson(extDataList.get(index).toString(), ProcessInfo_Data_prolenders.class);
    }

    public int getItemCount() {
        int result = 0;
        try {
            result = Integer.parseInt(itemCount);
        }catch (NumberFormatException e){
            e.printStackTrace();
        }
        return result;
    }

    public boolean isContact() {
        if (TextUtils.isEmpty(isContact)) return false;
        return isContact.equalsIgnoreCase("YES");
    }

    public String getContactParamName() {
        if (TextUtils.isEmpty(contactParamName)) return "";
        return contactParamName;
    }

    public ArrayList<String> getRelationShips(int index) {
        if (relationShips==null||relationShips.size()<=index) return new ArrayList<>();
        return relationShips.get(index);
    }

}
